package com.some;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class MaYi01 {
    public static int resultNum(int[] nums, int op, int i, int x) {
        if (op == 1) {
            nums[i - 1] = x;
            return -1;
        }
        if (op == 2) {
            int sum = 0;
            for (int j = 0; j < i; j++) {
                if (nums[j] == x) {
                    sum++;
                }
            }
            return sum;
        }
        return -1;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < q; i++) {
            int res = resultNum(nums, sc.nextInt(), sc.nextInt(), sc.nextInt());
            if (res != -1) {
                list.add(res);
            }
        }
        for (Integer integer : list) {
            System.out.println(integer);
        }
    }
}
